﻿using IdentityServer4.Models;
using System.Collections.Generic;

namespace JuCheap.Core.IdentityServer
{
    /// <summary>
    /// api资源站点配置
    /// </summary>
    public class JuCheapClients
    {
        /// <summary>
        /// api站点的Id
        /// </summary>
        public const string JuCheapApiId = "JuCheapApi";


        #region 定义要保护的资源（webapi）
        /// <summary>
        /// 获取api资源
        /// </summary>
        /// <returns></returns>
        public static IEnumerable<ApiResource> GetApiResources()
        {
            return new List<ApiResource>
            {
                new ApiResource(JuCheapApiId, "JuCheapApi Display Name")
            };
        }
        #endregion

        /// <summary>
        /// 获取客户端
        /// </summary>
        /// <returns></returns>
        public static IEnumerable<Client> GetClients()
        {
            return new List<Client>
            {
                new Client
                {
                    ClientId = JuCheapApiId,
                    AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,

                    ClientSecrets =
                    {
                        new Secret("FC3EE0275DE544B688AF6D3DE53AFF01".Sha256())
                    },
                    AllowedScopes = { JuCheapApiId }
                }
            };
        }
    }
}